# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2021/12/16 9:25
# @Author  : zuodengbo
# @Email   : zuodb@amoydx.com
# @File    : functions
# @Software: PyCharm
from lib.execute import limits_of_authority
from lib.public import pagination_data


def context_data(request, context):
    """
    分页获取数据处理
    """
    page = request.GET.dict().get('page', '1')
    paginator = context.get('paginator')
    page_obj = context.get('page_obj')
    is_paginated = context.get('is_paginated')
    data = pagination_data(paginator, page_obj, is_paginated)
    context.update(data)
    user_id = request.session.get('user_id', '')
    model_list = limits_of_authority(user_id)
    context.update({"model_list": model_list, "page": page})

    return context
